package db.prob.io;

import java.util.Arrays;

public class LineParser {

	public static PTuple createPTuple(String line, String seperator) {
		String[] pieces = line.split(seperator);
		
		if (pieces.length < 3) {
			throw new RuntimeException("Tuple has too few attributes!");
		}
		
		String tableName = pieces[0];
		float prob = Float.parseFloat(pieces[1]);
		String[] attr = Arrays.copyOfRange(pieces, 2, pieces.length);
		
		return new PTuple(tableName, prob, attr);
	}
}
